package git.soulbgm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import git.soulbgm.config.SysConfig;
import git.soulbgm.pojo.NodeInfo;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import git.soulbgm.pojo.SoftwareInfo;
import git.soulbgm.service.SoftwareInfoService;
import git.soulbgm.mapper.SoftwareInfoMapper;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 第三方软件信息表
 *
 * @author SoulBGM
 * @date 2020-11-18 10:03:05
 */
@Service
public class SoftwareInfoServiceImpl extends ServiceImpl<SoftwareInfoMapper, SoftwareInfo> implements SoftwareInfoService {

    /**
     * 获得所有缓存服务信息
     * Cacheable
     * value：缓存key的前缀。
     * key：缓存key的后缀。
     * sync：设置如果缓存过期是不是只放一个请求去请求数据库，其他请求阻塞，默认是false。
     *
     * @return {@link List}<{@link SoftwareInfo}>
     */
    @Cacheable(value = "softwareInfoAll", sync = true)
    @Override
    public List<SoftwareInfo> getCacheSoftwareInfoAll() {
        return list(new LambdaQueryWrapper<SoftwareInfo>().eq(SoftwareInfo::getRegionCode, SysConfig.getConfig().getRegionCode()));
    }

    @CacheEvict(value = {"softwareInfoClassify"}, allEntries = true)
    @Override
    public void clearCache() {
    }

}